package com.skivingcloud.feign.conf;

import feign.Logger;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author hushouquan
 */
@ConfigurationProperties
public class FeignClientBasicAuthRequestConfig{
    @Value("${skivingcloud.common.feign.username:''}")
    private String feignDefaultUser;
    @Value("${skivingcloud.common.feign.password:'~/klXz:zY*yB1e;7tc2A'}")
    private String feignDefaultPassword;
    /**
     * feign 日志打印
     * @return 日志
     */
    @Bean
    public Logger.Level getFeignLoggerLevel() {
        return Logger.Level.FULL;
    }
    
    /**
     *  Feign访问 认证授权
     * @return 认证信息
     */
    @Bean
    public BasicAuthRequestInterceptor getBasicAuthRequestInterceptor() {
        return new BasicAuthRequestInterceptor(feignDefaultUser, feignDefaultPassword);
    }
}
